package com.spzx.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spzx.user.domain.UserAddress;
import com.spzx.user.domain.UserInfo;
import com.spzx.user.mapper.UserInfoMapper;
import com.spzx.user.service.IUserAddressService;
import com.spzx.user.service.IUserInfoService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements IUserInfoService{
    @Resource
    private IUserAddressService userAddressService;
    @Override
    public List<UserInfo> selectUserInfoList(UserInfo userInfo)    {
        return baseMapper.selectUserInfoList(userInfo);
    }

    @Override
    public UserInfo getUserInfoById(Long id) {
        UserInfo userInfo = getById(id);
        List<UserAddress> list = userAddressService.list(new LambdaQueryWrapper<UserAddress>().eq(UserAddress::getUserId, id));
        userInfo.setUserAddressList(list);
        return userInfo;
    }

}
